package gui.panels.statistics;

import java.awt.Color;
import java.util.List;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.JTableHeader;

import common.types.Pair;

public class GameHistoryPanel extends JPanel implements StatisticsContent {

    private static final long serialVersionUID = 1L;

    private List<Pair<String,String>> gameHistory;
    
    @SuppressWarnings("serial")
    public GameHistoryPanel(List<Pair<String,String>> gameHistory) {
        
        this.gameHistory = gameHistory;
        
        setBackground(Color.WHITE);

        JTable table = new JTable(new GameHistoryTableModel(this.gameHistory)) {{
           setRowSelectionAllowed(false);
           setColumnSelectionAllowed(false);
           setCellSelectionEnabled(false);
           setDefaultRenderer(Object.class, new GameHistoryTableRenderer(0,13));
           setRowHeight(25);
           JTableHeader header = getTableHeader();
           header.setReorderingAllowed(false);
           header.setResizingAllowed(false);
           header.setDefaultRenderer(new GameHistoryTableRenderer(3,15));
        }};
        
        JScrollPane scrollPane = new JScrollPane(table);
        
        add(scrollPane);
    
    }

    @Override
    public String getTitle() {
        return "Game History";
    }

    @Override
    public JPanel getContent() {
        return this;
    }

    @Override
    public String getIconName() {
        return "data_grid.png";
    }

}
